文章目录
  1. 1. windeployqt.exe 发布程序
  2. 2. 环境问题

superhero

记录Qt Creator日常报错

  1. 中文乱码
    问题描述
    1
    warning: C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss

    warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失

解决办法:

  1. Qtcreator在fedora启动报错

Qtcreator启动报错

ubuntu下
用新立得安装如下这两个包,qt的帮助文档可能用了流媒体。
libgstreamer0.10-dev
libgstreamer-plugins-base0.10-dev

http://bbs.csdn.net/topics/391878342

http://www.itnpc.com/news/web/146163065659641.html

  1. newline in constant
    1
    error: C2001: newline in constant
    错误原因:输入了中文字符
    例如:
    编译器会报错的源码:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    void MainWindow::on_pushButton_13_clicked()  //`-`按键
    {
    what =1;
    next=pre;
    pre=" ";
    QString str;
    str=str.append("——"); //错误位置
    ui->Input->setText(str);
    }

str=str.append("——"); 改成str=str.append("-");即可

  1. qt creator无法编译Empty qmake project工程

检查.pro、源文件(.cpp)以及缺失存在QApplication文件存在之后仍然报以下错

1
Cannot open include file: 'QApplication': No such file or directory

解决办法:
执行qmake

  1. ‘cl’ 命令不识别
    1
    2
    3
    4
    5
    6
    7
    8
    9
    'cl' is not recognized as an internal or external command,
    operable program or batch file.
    jom: C:\Qt\Qt5.8.0\Examples\Qt-5.8\widgets\widgets\build-analogclock-Desktop_Qt_5_8_0_MSVC2015_64bit-Debug\Makefile.Debug [debug\main.obj] Error 1
    jom: C:\Qt\Qt5.8.0\Examples\Qt-5.8\widgets\widgets\build-analogclock-Desktop_Qt_5_8_0_MSVC2015_64bit-Debug\Makefile [debug] Error 2
    16:07:35: The process "C:\Qt\Qt5.8.0\Tools\QtCreator\bin\jom.exe" exited with code 2.
    Error while building/deploying project analogclock (kit: Desktop Qt 5.8.0 MSVC2015_64bit)
    The kit Desktop Qt 5.8.0 MSVC2015_64bit has configuration issues which might be the root cause for this problem.
    When executing step "Make"
    16:07:35: Elapsed time: 00:00.

同时打开对应版本的Developer Command Prompt for VS2015

1
2
3
'"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VCVarsQueryRegistry.bat"' is not recognized as an internal or external command,
operable program or batch file.
ERROR: Cannot determine the location of the VS installation.
  1. 没有头文件,环境问题

    1
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\crtdefs.h:10: error: C1083: Cannot open include file: 'corecrt.h': No such file or directory
  2. Qt动态加载dll

1
2
D:\gx_2017\2017-07\0\TVM_\Qt_CTicketTransportI_TVM\Qt_CTicketTransportI_TVM\main.cpp:-1: warning: C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
D:\gx_2017\2017-07\0\TVM_\Qt_CTicketTransportI_TVM\Qt_CTicketTransportI_TVM\main.cpp:27: error: C2664: 'HMODULE LoadLibraryW(LPCWSTR)': cannot convert argument 1 from 'const char [34]' to 'LPCWSTR'

解决:

1
2
    LPCWSTR dllname=L"equ_TicketTransportImpl_token.dll";
HINSTANCE hInst = LoadLibrary(dllname);
  1. 报错: 常量中有换行符换行符

解决:
在中文末尾加|即可消除中文编码报错的问题

  1. Cannot retrieve debugging output
    解决:
    开了2个Qt Creator;只留一个即可

  • 链接错误 LNK2019: 无法解析的外部符号 “public: __thiscall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
09:16:29: 为项目Qt_CCardRecycle_SZ7A执行步骤 ...
09:16:29: 配置没有改变, 跳过 qmake 步骤。
09:16:29: 正在启动 "C:\Qt\Qt5.8.0\Tools\QtCreator\bin\jom.exe"

C:\Qt\Qt5.8.0\Tools\QtCreator\bin\jom.exe -f Makefile.Debug
cl -c -nologo -Zc:wchar_t -FS -Zi -MDd -GR -W3 -w34100 -w34189 -w44996 -EHsc /Fddebug\Qt_CCardRecycle_SZ7A.vc.pdb -DUNICODE -DWIN32 -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I..\Qt_CCardRecycle_SZ7A -I. -IC:\Qt\Qt5.8.0\5.8\msvc2013\include -IC:\Qt\Qt5.8.0\5.8\msvc2013\include\QtWidgets -IC:\Qt\Qt5.8.0\5.8\msvc2013\include\QtGui -IC:\Qt\Qt5.8.0\5.8\msvc2013\include\QtANGLE -IC:\Qt\Qt5.8.0\5.8\msvc2013\include\QtCore -Idebug -I. -IC:\Qt\Qt5.8.0\5.8\msvc2013\mkspecs\win32-msvc2013 -Fodebug\ @C:\Users\sky\AppData\Local\Temp\mainwindow.obj.4524.31.jom
mainwindow.cpp
..\Qt_CCardRecycle_SZ7A\mainwindow.cpp(23) : warning C4189: “carrecyle”: 局部变量已初始化但不引用
link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST:embed /OUT:debug\Qt_CCardRecycle_SZ7A.exe @C:\Users\sky\AppData\Local\Temp\Qt_CCardRecycle_SZ7A.exe.4524.5085.jom
正在创建库 debug\Qt_CCardRecycle_SZ7A.lib 和对象 debug\Qt_CCardRecycle_SZ7A.exp
mainwindow.obj : error LNK2019: 无法解析的外部符号 "public: __thiscall CCardRecycle_SZ7A::CCardRecycle_SZ7A(void)" (??0CCardRecycle_SZ7A@@QAE@XZ),该符号在函数 "public: __thiscall MainWindow::MainWindow(class QWidget *)" (??0MainWindow@@QAE@PAVQWidget@@@Z) 中被引用
debug\Qt_CCardRecycle_SZ7A.exe : fatal error LNK1120: 1 个无法解析的外部命令
jom: C:\Users\sky\Desktop\ICardRecycleImpl_SZ7A\Qt_CCardRecycle_SZ7A\build-Qt_CCardRecycle_SZ7A-Desktop_Qt_5_8_0_MSVC2013_32bit-Debug\Makefile.Debug [debug\Qt_CCardRecycle_SZ7A.exe] Error 1120
jom: C:\Users\sky\Desktop\ICardRecycleImpl_SZ7A\Qt_CCardRecycle_SZ7A\build-Qt_CCardRecycle_SZ7A-Desktop_Qt_5_8_0_MSVC2013_32bit-Debug\Makefile [debug] Error 2
09:16:35: 进程"C:\Qt\Qt5.8.0\Tools\QtCreator\bin\jom.exe"退出,退出代码 2
Error while building/deploying project Qt_CCardRecycle_SZ7A (kit: Desktop Qt 5.8.0 MSVC2013 32bit)
The kit Desktop Qt 5.8.0 MSVC2013 32bit has configuration issues which might be the root cause for this problem.
When executing step "Make"
09:16:35: Elapsed time: 00:06.

windeployqt.exe 发布程序

1
2
3
4
C:\Qt\Qt5.4.1\5.4\msvc2013\bin>windeployqt.exe D:\gx_2017\2017-07\0\TVM_\Qt_CTicketTransportI_TVM\build-Qt_CTicketTransportI_TVM-Desktop_Qt_5_4_1_MSVC2013_32bit-Debug\debug\Qt_CTicketTransportI_TVM.exe
Qt: Untested Windows version 10.0 detected!
D:\gx_2017\2017-07\0\TVM_\Qt_CTicketTransportI_TVM\build-Qt_CTicketTransportI_TVM-Desktop_Qt_5_4_1_MSVC2013_32bit-Debug\debug\Qt_CTicketTransportI_TVM.exe 32 bit, debug executable
Unable to locate ICU library icuin53.dl

解决:

环境问题

  1. 缺少core.h文件

[][]

文章目录
  1. 1. windeployqt.exe 发布程序
  2. 2. 环境问题